package com.example.hospital.service.impl;



import com.example.hospital.mapper.ScheduleMapper;
import com.example.hospital.pojo.Schedule;
import com.example.hospital.service.ScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Date;

@Service
public class ScheduleServiceImpl implements ScheduleService {

    @Autowired
    private ScheduleMapper scheduleMapper;

    // 获取特定用户的排班
    @Override
    public List<Schedule> getSchedulesByUserId(Integer userId) {
        return scheduleMapper.findByUserId(userId);
    }

    // 获取所有排班
    @Override
    public List<Schedule> getAllSchedules() {
        return scheduleMapper.findAll();
    }

    // 根据ID获取排班
    @Override
    public Schedule getScheduleById(Integer id) {
        return scheduleMapper.findById(id);
    }

    // 创建排班
    @Override
    public void createSchedule(Schedule schedule) {
        scheduleMapper.insertSchedule(schedule);
    }

    // 更新排班
    @Override
    public void updateSchedule(Schedule schedule) {
        scheduleMapper.updateSchedule(schedule);
    }

    // 删除排班
    @Override
    public void deleteSchedule(Integer id) {
        scheduleMapper.deleteSchedule(id);
    }

    // 根据日期范围获取排班
    @Override
    public List<Schedule> getSchedulesByDateRange(Date startDate, Date endDate) {
        return scheduleMapper.findByDateRange(startDate, endDate);
    }
}
